<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Order';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;
	
	$api->resource('orders', "OrderController", ['only' => $allMethod]);
	$api->get('/order-stat/total', ['uses' => "OrderStatController@totalStat"]);
	
	$api->get('/express-list', ['uses' => "ExpressController@index"]);

	$api->post('/batch-deliver', ['uses'=> "DeliverController@batchDeliver"]);
	$api->post('/submit-batch-deliver', ['uses'=> "DeliverController@submit"]);

	$api->post('/export/orders', ['uses'=> "OrderExportController@store"]);
	$api->post('/export/order-total', ['uses'=> "OrderExportController@total"]);
	$api->get('/export/orders/{uuid}', ['uses'=> "OrderExportController@show"]);

	// 售后详情
	$api->get('aftersales/{uuid}', ['uses' => "AftersaleController@show"]);
	$api->put('aftersales/{uuid}', ['uses' => "AftersaleController@update"]);
});

// 租户api
// $api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
// 	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
// });

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
    //供应链推送消息
    $api->post('/get_deliver_order', ['uses' => "OrderController@getDeliverOrder"]);
    $api->post('/get_order_wuliu/{orderSn}/{sku}', ['uses' => "OrderController@getwuliu"]);
    
	$api->post('/preview-orders', ['uses' => "PreviewOrderController@store"]);
	$api->get('/close-order-reasons', ['uses' => "OrderController@closeReasons"]);
	
	$api->resource('orders', "OrderController", ['only' => $allMethod]);

	// 获取订单状态
	$api->get('/order-stat', ['uses' => "OrderStatController@totalStat"]);

	// 线下订单核销所需信息
	$api->get('orders/{uuid}/offline/verify-info', ['uses' => "OrderOfflineController@verifyInfo"]);

	// 管理员扫码获取信息
	$api->post('order/scan', ['uses' => "OrderOfflineController@scan"]);
	// 管理员确认核销
	$api->post('order/scan/confirm', ['uses' => "OrderOfflineController@scanConfirm"]);

	$api->get('orders/{uuid}/return-sale-info', ['uses' => "ReturnSaleController@info"]);
	$api->post('orders/{uuid}/return-sale', ['uses' => "ReturnSaleController@store"]);

	$api->get('orders/{uuid}/comment-skus', ['uses' => "OrderCommentController@skus"]);
	$api->get('orders/{uuid}/comments', ['uses' => "OrderCommentController@store"]);

	// 代付记录详情
	$api->get('agent-pay-records/{uuid}', ['uses' => "AgentPayRecordController@show"]);

	// 发起代付支付
	$api->post('agent-pay-records/{uuid}/pay', ['uses' => "AgentPayRecordController@pay"]);

    // 创建售后
	$api->post('aftersales', ['uses' => "AftersaleController@store"]);
	// 售后详情
	$api->get('aftersales/{uuid}', ['uses' => "AftersaleController@show"]);
	$api->put('aftersales/{uuid}', ['uses' => "AftersaleController@update"]);
});